﻿package net.wangit.view.chart.impl;

import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer3D;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.urls.StandardCategoryURLGenerator;
import org.jfree.data.category.CategoryDataset;
import org.jfree.util.SortOrder;

public class Bar3DChart extends CategoryChart {

	public Bar3DChart() {
	}

	protected CategoryPlot getCategoryPlot() {
		CategoryDataset dataset = (CategoryDataset) getDataset();
		org.jfree.chart.axis.CategoryAxis categoryAxis = getCategoryAxis3D();
		org.jfree.chart.axis.ValueAxis valueAxis = getNumberAxis3D();
		CategoryItemRenderer renderer = getRenderer();
		CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
				renderer);
		if (orientation == PlotOrientation.HORIZONTAL) {
			plot.setRowRenderingOrder(SortOrder.DESCENDING);
			plot.setColumnRenderingOrder(SortOrder.DESCENDING);
		}
		plot.setForegroundAlpha(0.75F);
		return plot;
	}

	private CategoryItemRenderer getRenderer() {
		BarRenderer3D renderer = new BarRenderer3D();
		if (tooltips)
			renderer
					.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
		if (urls)
			renderer
					.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
		configCategoryRenderer(renderer);
		return renderer;
	}
}
